package com.gqj.elec.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gqj.common.annotation.Log;
import com.gqj.common.core.controller.BaseController;
import com.gqj.common.core.domain.AjaxResult;
import com.gqj.common.enums.BusinessType;
import com.gqj.elec.domain.ElecWarningDetail;
import com.gqj.elec.service.IElecWarningDetailService;
import com.gqj.common.utils.poi.ExcelUtil;
import com.gqj.common.core.page.TableDataInfo;

/**
 * 物资报警详情Controller
 * 
 * @author lxq
 * @date 2023-09-02
 */
@RestController
@RequestMapping("/elec/elecWarningDetail")
public class ElecWarningDetailController extends BaseController
{
    @Autowired
    private IElecWarningDetailService elecWarningDetailService;

    /**
     * 查询物资报警详情列表
     */
    @PreAuthorize("@ss.hasPermi('elec:elecWarningDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(ElecWarningDetail elecWarningDetail)
    {
        startPage();
        List<ElecWarningDetail> list = elecWarningDetailService.selectElecWarningDetailList(elecWarningDetail);
        return getDataTable(list);
    }

    /**
     * 导出物资报警详情列表
     */
    @PreAuthorize("@ss.hasPermi('elec:elecWarningDetail:export')")
    @Log(title = "物资报警详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElecWarningDetail elecWarningDetail)
    {
        List<ElecWarningDetail> list = elecWarningDetailService.selectElecWarningDetailList(elecWarningDetail);
        ExcelUtil<ElecWarningDetail> util = new ExcelUtil<ElecWarningDetail>(ElecWarningDetail.class);
        util.exportExcel(response, list, "物资报警详情数据");
    }

    /**
     * 获取物资报警详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('elec:elecWarningDetail:query')")
    @GetMapping(value = "/{warningDetailId}")
    public AjaxResult getInfo(@PathVariable("warningDetailId") Long warningDetailId)
    {
        return AjaxResult.success(elecWarningDetailService.selectElecWarningDetailByWarningDetailId(warningDetailId));
    }

    /**
     * 新增物资报警详情
     */
    @PreAuthorize("@ss.hasPermi('elec:elecWarningDetail:add')")
    @Log(title = "物资报警详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElecWarningDetail elecWarningDetail)
    {
        return toAjax(elecWarningDetailService.insertElecWarningDetail(elecWarningDetail));
    }

    /**
     * 修改物资报警详情
     */
    @PreAuthorize("@ss.hasPermi('elec:elecWarningDetail:edit')")
    @Log(title = "物资报警详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElecWarningDetail elecWarningDetail)
    {
        return toAjax(elecWarningDetailService.updateElecWarningDetail(elecWarningDetail));
    }

    /**
     * 删除物资报警详情
     */
    @PreAuthorize("@ss.hasPermi('elec:elecWarningDetail:remove')")
    @Log(title = "物资报警详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warningDetailIds}")
    public AjaxResult remove(@PathVariable Long[] warningDetailIds)
    {
        return toAjax(elecWarningDetailService.deleteElecWarningDetailByWarningDetailIds(warningDetailIds));
    }
}
